﻿

function BusinessUnit(model) {

    RajonViewModel.prototype.constructor.apply(this);
    this.model = model;

    this.openLevel = function () {

        // if its open, just close
        if (this.isOpen()) {
            this.childrenView().style.display = 'none';
            this.refresh(); // refreshs the folder image
            return;
        }

        // other wise, bind and open
        this.childrenView().style.display = 'block';
        this.childrenView().vmodel.bind();
        this.refresh(); // refreshs the folder image
    }

    this.isOpen = function() {
        return (this.childrenView().style.display!='none');
    }

    this.childrenView = function () {
        return $('div', this.getView())[0];
    }

    this.UnitImage = function() {
        if(this.isOpen())
            return './images/openUnit.jpg';

        return './images/closeUnit.jpg';
    }

}
    
    
BusinessUnit.prototype = new RajonViewModel();
